//
//  DKFaqQueryEndCell.m
//  DanKU
//
//  Created by 吴斌 on 2023/11/12.
//

#import "DKFaqQueryEndCell.h"

static NSString * FaqQueryEndCellTableId = @"FaqQueryEndCellTableId";
@interface DKFaqQueryEndCell()
@property (nonatomic, strong)UILabel * faqSourchHeadLab;
@property (nonatomic, strong)UIButton * faqSourchUnresolvedBtn;
@property (nonatomic, strong)UIButton * faqSourchResolvedBtn;
@property (nonatomic, strong)UILabel * faqSourchResultLab;

@end
@implementation DKFaqQueryEndCell
+ (instancetype)faqQueryEndCell:(UITableView *)tableView{
    DKFaqQueryEndCell * faqQueryCell = [tableView dequeueReusableCellWithIdentifier:FaqQueryEndCellTableId];
    if (!faqQueryCell) {
        faqQueryCell = [[DKFaqQueryEndCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:FaqQueryEndCellTableId];
    }
    faqQueryCell.backgroundColor = [UIColor whiteColor];
    faqQueryCell.selectionStyle = UITableViewCellSelectionStyleNone;
    faqQueryCell.accessoryType = UITableViewCellAccessoryNone;
    return faqQueryCell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self creatSubView];
    }
    return self;
}
- (void)creatSubView{
    self.faqSourchHeadLab = [[UILabel alloc] init];
    self.faqSourchHeadLab.textColor = DK_Hex(@"#363A3B");
    self.faqSourchHeadLab.font = DK_FONT_Medium(13);
    self.faqSourchHeadLab.text = @"Is there any solution to your problem?";
    self.faqSourchHeadLab.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.faqSourchHeadLab];
    [self.faqSourchHeadLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@(DK_IsWidthScale(20)));
        make.left.equalTo(@(DK_IsWidthScale(0)));
        make.right.equalTo(@(-DK_IsWidthScale(0)));
        make.height.equalTo(@(DK_IsWidthScale(18)));
    }];
    self.faqSourchUnresolvedBtn = [[UIButton alloc] init];
    [self.faqSourchUnresolvedBtn setImage:DK_GetImage(@"dk_MeFaq_UnresolvedNoSelect") forState:UIControlStateNormal];
    [self.faqSourchUnresolvedBtn setImage:DK_GetImage(@"dk_MeFaqSourch_UnresolvedSelect") forState:UIControlStateSelected];
    [self.faqSourchUnresolvedBtn setTitleColor:DK_Hex(@"#B7B7B7") forState:UIControlStateNormal];
    [self.faqSourchUnresolvedBtn setTitleColor:DK_Hex(@"#00D7FF") forState:UIControlStateSelected];
    [self.faqSourchUnresolvedBtn setTitle:@" Unresolved" forState:UIControlStateNormal];
    [self.faqSourchUnresolvedBtn setTitle:@" Unresolved" forState:UIControlStateSelected];
    [self.faqSourchUnresolvedBtn setBackgroundColor:UIColor.clearColor];
    self.faqSourchUnresolvedBtn.titleLabel.font = DK_FONT_Regular(12);
    [self.faqSourchUnresolvedBtn addTarget:self action:@selector(faqSourchUnresolved) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:self.faqSourchUnresolvedBtn];
    [self.faqSourchUnresolvedBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.faqSourchHeadLab.mas_bottom).offset(DK_IsWidthScale(18));
        make.left.equalTo(@(DK_IsWidthScale(23)));
        make.width.equalTo(@(DK_IsWidthScale(140)));
        make.height.equalTo(@(DK_IsWidthScale(38)));
    }];
    self.faqSourchResolvedBtn = [[UIButton alloc] init];
    [self.faqSourchResolvedBtn setImage:DK_GetImage(@"dk_MeFaq_ResolvedNoSelect") forState:UIControlStateNormal];
    [self.faqSourchResolvedBtn setImage:DK_GetImage(@"dk_MeFaqSourch_ResolvedSelect") forState:UIControlStateSelected];
    [self.faqSourchResolvedBtn setTitleColor:DK_Hex(@"#B7B7B7") forState:UIControlStateNormal];
    [self.faqSourchResolvedBtn setTitleColor:DK_Hex(@"#00D7FF") forState:UIControlStateSelected];
    [self.faqSourchResolvedBtn setTitle:@" Resolved" forState:UIControlStateNormal];
    [self.faqSourchResolvedBtn setTitle:@" Resolved" forState:UIControlStateSelected];
    [self.faqSourchResolvedBtn setBackgroundColor:UIColor.clearColor];
    self.faqSourchResolvedBtn.titleLabel.font = DK_FONT_Regular(12);
    [self.faqSourchResolvedBtn addTarget:self action:@selector(faqSourchResolved) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:self.faqSourchResolvedBtn];
    [self.faqSourchResolvedBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.faqSourchUnresolvedBtn);
        make.right.equalTo(@(-DK_IsWidthScale(23)));
        make.width.equalTo(@(DK_IsWidthScale(140)));
        make.height.equalTo(self.faqSourchUnresolvedBtn);
        make.bottom.equalTo(@(-DK_IsWidthScale(16)));
    }];
    self.faqSourchResultLab = [[UILabel alloc] init];
    self.faqSourchResultLab.textColor = DK_Hex(@"#363A3B");
    self.faqSourchResultLab.font = DK_FONT_Medium(13);
    self.faqSourchResultLab.text = @"Thanks for your feedback!";
    self.faqSourchResultLab.textAlignment = NSTextAlignmentCenter;
    self.faqSourchResultLab.hidden = YES;
    [self.contentView addSubview:self.faqSourchResultLab];
    [self.faqSourchResultLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.centerX.equalTo(self.contentView);
        make.height.equalTo(@(DK_IsWidthScale(18)));
    }];
}
-(void)layoutSublayersOfLayer:(CALayer *)layer{
    [super layoutSublayersOfLayer:layer];
    [self makeCornerOnBottomleftRight:DK_IsWidthScale(10)];
}
- (void)faqSourchUpdata{
    _faqSourchUnresolvedBtn.selected = NO;

}
- (void)faqSourchUnresolved{
    _faqSourchUnresolvedBtn.selected = YES;
    if(self.UpdataUnresolvedBlock){
        self.UpdataUnresolvedBlock();
    }
}
- (void)faqSourchResolved{
    _faqSourchResolvedBtn.selected = YES;
    self.faqSourchResultLab.hidden = NO;
    self.faqSourchHeadLab.hidden = YES;
    self.faqSourchUnresolvedBtn.hidden = YES;
    self.faqSourchResolvedBtn.hidden = YES;
    [DKAlertHelper showMessage:@"Thanks for your feedback!"];
}
@end
